//
//  TCPManager.h
//  LazyHome
//
//  Created by yh on 2018/3/30.
//  Copyright © 2018年 yh. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "TCPClient.h"
#import "LHMessage.h"
@protocol TCPManagerDelegate

- (TCPClient *)creatClientWithHost:(NSString *)host
                         port:(NSString *)port
                    localport:(NSString *)localport
                        error:(NSError **)errPtr;

- (void)sendMessage:(LHMessage *)msg toClient:(TCPClient *)clinet success:(void(^)(LHMessage *message))success failure:(void(^)(void))failure;


/**
 发送消息

 @param msg <#msg description#>
 @param clinet <#clinet description#>
 @param success <#success description#>
 @param failure <#failure description#>
 @param inQueue 是否使用队列，入过使用队列，一旦出现网络不通的时候,会暂停发送，网络恢复后自动重发,一般用于后台任务请求,不适用于用户主动点击请求
 */
- (void)sendMessage:(LHMessage *)msg toClient:(TCPClient *)clinet success:(void(^)(LHMessage *message))success failure:(void(^)(void))failure inQueue:(BOOL)inQueue;

@end


extern NSString *const NOTI_TCP_MESSAGE_CAME;
@interface TCPManager : NSObject<TCPClientDelegate,TCPManagerDelegate>
@property (nonatomic, strong) NSMutableArray<TCPClient *> *clients;


@end
